/**
 * Created by Zorro on 2/24 024.
 */
Ext.define('cfWeb.view.appAudit.ServiceConfigListView', {
    extend : 'Ext.panel.Panel',
    alias : 'widget.serviceConfigListView',
    selfId: undefined,
    cls:'style-ServiceConfigView',
    title:cfWebLang.HomeTabView.dataStorageService,
    header:{
        height:40
    },
//	titleCollapse : true,
    items: [{
        xtype: 'form',
        name: 'ServiceConfigList.Form',
        border: false,
        padding: '20 20 0 20',
        defaults: {
            labelWidth: 30,
            cls: 'appPanel-input',
            labelStyle: 'color:#2a3950'
        },
        items: [{
            xtype: 'fieldset',
            itemId: 'mysqlFieldSet',
            store: Ext.create('cfWeb.store.dataStorage.DatabaseServiceStore'),
            layout: 'hbox',
            hidden: true,
            items:[{
                xtype: 'label',
                text: 'MySQL',
                width: 60
            }, {
                xtype:'combobox',
                name:'mysql.service',
                fieldLabel:'service',
                store:Ext.create('cfWeb.store.dataStorage.DatabaseServiceBrokerStore'),
                labelWidth: 80,
                queryMode : 'local',
                displayField:'label',
                valueField:'label',
                emptyText:cfWebLang.Util.ChooseService,
                labelAlign:'right',
                editable : false,
                listeners: {
                    change: function (me) {
                        var store = me.up('fieldset').store;
                        var service = me.getValue();
                        var planStore = me.up('fieldset').down('combobox[name=' + me.name.split('.')[0] + '.plan]').getStore();
                        planStore.loadData(store.findRecord('label', service).get('plans'));
                    }
                }
            }, {
                xtype:'combobox',
                name:'mysql.plan',
                queryMode : 'local',
                store:Ext.create('cfWeb.store.dataStorage.DatabaseBrokerPlanStore'),
                fieldLabel:'servicePlan',
                labelWidth: 110,
                displayField:'name',
                valueField:'name',
                emptyText:cfWebLang.Util.ChoosePlan ,
                labelAlign:'right',
                editable : false
            }]
        }, {
            xtype: 'fieldset',
            itemId: 'oracleFieldSet',
            store: Ext.create('cfWeb.store.dataStorage.DatabaseServiceStore'),
            layout: 'hbox',
            hidden: true,
            items:[{
                xtype: 'label',
                text: 'Oracle',
                width: 60
            }, {
                xtype:'combobox',
                name:'oracle.service',
                fieldLabel:'service',
                store:Ext.create('cfWeb.store.dataStorage.DatabaseServiceBrokerStore'),
                labelWidth: 80,
                queryMode : 'local',
                displayField:'label',
                valueField:'label',
                emptyText:cfWebLang.Util.ChooseService,
                labelAlign:'right',
                editable : false,
                listeners: {
                    change: function (me) {
                        var store = me.up('fieldset').store;
                        var service = me.getValue();
                        var planStore = me.up('fieldset').down('combobox[name=' + me.name.split('.')[0] + '.plan]').getStore();
                        planStore.loadData(store.findRecord('label', service).get('plans'));
                    }
                }
            }, {
                xtype:'combobox',
                name:'oracle.plan',
                queryMode : 'local',
                store:Ext.create('cfWeb.store.dataStorage.DatabaseBrokerPlanStore'),
                fieldLabel:'servicePlan',
                labelWidth: 110,
                displayField:'name',
                valueField:'name',
                emptyText:cfWebLang.Util.ChoosePlan ,
                labelAlign:'right',
                editable : false
            }]
        }, {
            xtype: 'fieldset',
            itemId: 'redisFieldSet',
            store: Ext.create('cfWeb.store.dataStorage.DatabaseServiceStore'),
            layout: 'hbox',
            hidden: true,
            items:[{
                xtype: 'label',
                text: 'Redis',
                width: 60
            }, {
                xtype:'combobox',
                name:'redis.service',
                fieldLabel:'service',
                store:Ext.create('cfWeb.store.dataStorage.DatabaseServiceBrokerStore'),
                labelWidth: 80,
                queryMode : 'local',
                displayField:'label',
                valueField:'label',
                emptyText:cfWebLang.Util.ChooseService,
                labelAlign:'right',
                editable : false,
                listeners: {
                    change: function (me) {
                        var store = me.up('fieldset').store;
                        var service = me.getValue();
                        var planStore = me.up('fieldset').down('combobox[name=' + me.name.split('.')[0] + '.plan]').getStore();
                        planStore.loadData(store.findRecord('label', service).get('plans'));
                    }
                }
            }, {
                xtype:'combobox',
                name:'redis.plan',
                queryMode : 'local',
                store:Ext.create('cfWeb.store.dataStorage.DatabaseBrokerPlanStore'),
                fieldLabel:'servicePlan',
                labelWidth: 110,
                displayField:'name',
                valueField:'name',
                emptyText:cfWebLang.Util.ChoosePlan ,
                labelAlign:'right',
                editable : false
            }]
        }, {
            xtype: 'fieldset',
            itemId: 'rabbitmqFieldSet',
            store: Ext.create('cfWeb.store.dataStorage.DatabaseServiceStore'),
            layout: 'hbox',
            hidden: true,
            items:[{
                xtype: 'label',
                text: 'RabbitMQ',
                width: 60
            }, {
                xtype:'combobox',
                name:'rabbitmq.service',
                fieldLabel:'service',
                store:Ext.create('cfWeb.store.dataStorage.DatabaseServiceBrokerStore'),
                labelWidth: 80,
                queryMode : 'local',
                displayField:'label',
                valueField:'label',
                emptyText:cfWebLang.Util.ChooseService,
                labelAlign:'right',
                editable : false,
                listeners: {
                    change: function (me) {
                        var store = me.up('fieldset').store;
                        var service = me.getValue();
                        var planStore = me.up('fieldset').down('combobox[name=' + me.name.split('.')[0] + '.plan]').getStore();
                        planStore.loadData(store.findRecord('label', service).get('plans'));
                    }
                }
            }, {
                xtype:'combobox',
                name:'rabbitmq.plan',
                queryMode : 'local',
                store:Ext.create('cfWeb.store.dataStorage.DatabaseBrokerPlanStore'),
                fieldLabel:'servicePlan',
                labelWidth: 110,
                displayField:'name',
                valueField:'name',
                emptyText:cfWebLang.Util.ChoosePlan ,
                labelAlign:'right',
                editable : false
            }]
        }]
    }],
    initComponent : function() {
        this.addEvents({
        });
        this.callParent(arguments);
    },
    listeners:{
        boxready : function(){
            this.selfId = this.getEl().id;
            this.eventBind();
        }
    },
    getTarNode :function(tar,tag){
        if(tar.tagName ==undefined){
            return false;
        }
        var res = tar.getAttribute(tag);
        if(res != null && res.length > 0){
            return tar;
        }
        else{
            return this.getTarNode(tar.parentNode,tag);
        }
    },
    eventBind :function(){
//	   var header = this.header.getEl();
//	   header.on('click',this.headClick,this);
//	   console.log(header);
    }
});
